﻿//-----------------------------------------------------------------------
// <copyright file="Default.aspx.cs" company="CMSN Software">
//    Copyright © 2010  CMSN Software
//    This program is free software: you can redistribute it and/or modify
//    it under the terms of the GNU General Public License as published by
//    the Free Software Foundation, either version 3 of the License, or
//    (at your option) any later version.
//
//    This program is distributed in the hope that it will be useful,
//    but WITHOUT ANY WARRANTY; without even the implied warranty of
//    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
//    GNU General Public License for more details.
//
//    You should have received a copy of the GNU General Public License
//    along with this program.  If not, see http://www.gnu.org/licenses.
// </copyright>
//-----------------------------------------------------------------------        
namespace MicrosoftAjaxSample
{
    using System;
    using System.Diagnostics.CodeAnalysis;
    using System.IO;
    using System.Text;

    /// <summary>
    /// Code behind of the Default.aspx
    /// </summary>
    [SuppressMessage("Microsoft.Naming", "CA1707:IdentifiersShouldNotContainUnderscores", Justification = "Generatd By IDE")]
    public partial class _Default : System.Web.UI.Page
    {
        /// <summary>
        /// File to read via ajax
        /// </summary>
        private const string FileToLoad = "AjaxResponse.txt";

        /// <summary>
        /// Handles the Load event of the Page control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param>
        protected void Page_Load(object sender, EventArgs e)
        {
        }

        /// <summary>
        /// Handles the Click event of the SimpleAjaxRequestButton control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param>
        protected void SimpleAjaxRequestButton_Click(object sender, EventArgs e)
        {
            // create reader & open file
            using (StreamReader fileContent = new StreamReader(FileToLoad))
            {
                StringBuilder content = null;
                while (fileContent.ReadLine() != null)
                {
                    content.Append(fileContent.ReadLine());
                }

                this.SimpleAjaxResponse.InnerHtml = content.ToString();
            }
        }
    }
}
